﻿@{
    ViewBag.Title = "Cart";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@{
    var DealInCart = Model;
       
}
    <div id="random_deal">
	<div class="title-content">GIỎ HÀNG</div></th>
    <br />
    <br/>
    <h5>Dưới đây là các sản phẩm hiện có trong giỏ hàng của bạn, chọn thanh toán để tiếp tục.</h5>
      <div>&nbsp;</div>      
      <table width="100%" style="border:1px #333 solid ; border-collapse:collapse; border-spacing: 0px;">
  <tr>
    <td width="5%"  class="namecolumn">STT</td>
    <td width="31%"  class="namecolumn">Tên sản phẩm</td>
    <td width="27%"  class="namecolumn">Giá tiền</td>
    <td width="31%"  class="namecolumn">Số lượng</td>
    <td width="6%"  class="namecolumn"></td>
  </tr>
  @if (DealInCart.Count != 0)
  {
      var nDealInCart = DealInCart.Count;
      for (int i = 0; i < nDealInCart; i++)
      {
          var deal = DealInCart[i];
          var selectedIndex = ViewBag.ListQuantity[i];
  <tr  style="border-bottom:2px #666 solid;">
    <td class="textcolumn">@(i + 1)</td>
    <td class="textcolumn"><a href="@Url.Action("Detail", "Produce", new { dealID = @deal.DealID })">@deal.DealName</a></td>
    <td class="textcolumn">@deal.Discount</td>

<form method="post" action="@Url.Action("EditCart", "Member", new { id = @deal.DealID })">
    <td class="textcolumn"><select id="quantity" name="count" onchange="this.form.submit()">
        @{     
          for (int j = 0; j < 5; j++)
          {
              var optionID = j + 1;
              if (optionID == selectedIndex)
              {
                     <option value="@optionID" selected="true">@optionID</option>
              }
              else
              {    
                    <option value="@optionID">@optionID</option>
              }
          }
        }
    </select></td>
</form>

    <td class="textcolumn"><a href="@Url.Action("Delete", "Member", new { id = @deal.DealID })" style="text-decoration:none;">Xóa <li class="ui-state-default ui-corner-all" title=".ui-icon-closethick"><span class="ui-icon ui-icon-closethick"></span></li></a></td>
  </tr>
      }
  }
  else { 
    <p>Khong co san pham trong gio</p>
  }
</table>

        <div class="row">
                    <div class="midle">
                        <form method="post" action="@Url.Action("GetMore","Member")">
                            <input class="submit-form" name="submit" value="Thêm mới" type="submit" />
                        </form>
                        </div>
                    <div class="midle">
                        <form method="post" action="@Url.Action("DeleteAll","Member")">
                            <input name="submit" type="submit" class="submit-form" value="Bỏ tất cả" />
                        </form>
                        </div>
                    <div class="midle">
                        <form method="post" action="@Url.Action("CheckOut","Member")">
                            <input name="submit" type="submit" class="submit-form" value="Thanh toán" />
                        </form>
                        </div>
      </div>
    </div>    
  <table width="100%"></table>
